<?php
/**
 * @Author: CaiHongxuan
 * @Date:   2016-03-17 15:15:03
 * @Last Modified by:   CaiHongxuan
 * @Last Modified time: 2016-03-18 00:16:03
 */
class IndexModel extends Model{
	/**
	 * 回复关注subscribe事件
	 * @param  [type] $postObj [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function responseSubscribe($postObj, $content){
		$toUsername   = $postObj->FromUserName;
	    $fromUsername = $postObj->ToUserName;
	    $time         = time();
	    $msgType      = 'text';
	    $template     = "<xml>
	                    <ToUserName><![CDATA[%s]]></ToUserName>
	                    <FromUserName><![CDATA[%s]]></FromUserName>
	                    <CreateTime>%s</CreateTime>
	                    <MsgType><![CDATA[%s]]></MsgType>
	                    <Content><![CDATA[%s]]></Content>
	                    <FuncFlag>0</FuncFlag>
	                    </xml>";
	    $resultStr = sprintf($template, $toUsername, $fromUsername, $time, $msgType, $content);
	    return $resultStr;
	}

	/**
	 * 回复文本消息
	 * @param  [type] $postObj [description]
	 * @param  [type] $content [description]
	 * @return [type]          [description]
	 */
	public function responseText($postObj, $content){
		$toUsername   = $postObj->FromUserName;
        $fromUsername = $postObj->ToUserName;
        $time         = time();
		$msgType      = "text";
        $template     = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[%s]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        </xml>";
		$resultStr = sprintf($template, $toUsername, $fromUsername, $time, $msgType, $content);
        return $resultStr;
	}

}
